import {
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect,
} from 'react-router-dom'

import './App.scss'

// 导入页面
import Layout from './pages/Layout'
// import Layout from '@/pages/Layout'
import Login from './pages/Login'
import NotFound from './pages/NotFound'
import { AuthRoute } from '@/components/AuthRoute'

const App = () => {
  return (
    <Router>
      <div className="app">
        <Switch>
          {/* 
            exact 表示：让路由变为精确匹配，也就是只有当路由地址为 / 才匹配
            当前路由用来实现重定向功能：也就是在进入项目时，就匹配默认路由，然后，直接重定向到 /home 页面
          */}
          <Route path="/" exact render={() => <Redirect to="/login" />} />
          <AuthRoute path="/home" component={Layout} />
          <Route path="/login" component={Login} />
          {/* 404 */}
          <Route>
            <NotFound />
          </Route>
          login
        </Switch>
      </div>
    </Router>
  )
}

export default App
